<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%--<%@ taglib prefix="s" uri="/struts-tags" %>--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <meta name="description" content=""/>
    <meta name="author" content=""/>
    <title></title>
    <!--favicon-->
    <link rel="icon" href="assets/images/favicon.ico" type="image/x-icon">
    <!-- simplebar CSS-->
    <link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet"/>
    <!-- Bootstrap core CSS-->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
    <!--Data Tables -->
    <link href="assets/plugins/bootstrap-datatable/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css">
    <link href="assets/plugins/bootstrap-datatable/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css">
    <!-- animate CSS-->
    <link href="assets/css/animate.css" rel="stylesheet" type="text/css"/>
    <!-- Icons CSS-->
    <link href="assets/css/icons.css" rel="stylesheet" type="text/css"/>
    <!-- Sidebar CSS-->
    <link href="assets/css/sidebar-menu.css" rel="stylesheet"/>
    <!-- Custom Style-->
    <link href="assets/css/app-style.css" rel="stylesheet"/>
    <!-- Bootstrap core CSS-->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function aa(stno, sname, tel, major, stuclass) {
            document.getElementById("stno").value = stno;
            document.getElementById("sname").value = sname;
            document.getElementById("tel").value = tel;
            document.getElementById("major").value = major;
            document.getElementById("stuclass").value = stuclass;


        }
    </script>
</head>

<body>
<div class="container-fluid" id="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header"><i class="fa fa-table"></i> 学生基础信息表</div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="example" class="table table-bordered">
                        <thead>
                            <b>
                                <tr>
                                    <th style="font-size: 12px;width: 30px;">学号</th>
                                    <th style="font-size: 12px;width: 30px;">学生姓名</th>
                                    <th style="font-size: 12px;width: 30px;">联系电话</th>
                                    <th style="font-size: 12px;width: 30px;">专业</th>
                                    <th style="font-size: 12px;width: 30px;">班级</th>
                                    <th style="font-size: 12px;">操作</th>
                                </tr>
                            </b>
                            </thead>
                            <tbody>
                            <!--描述：表开始 -->
                            <c:forEach items="${list}" var="stu">
                                <tr>
                                    <td>${stu.stno }</td>
                                    <td>${stu.sname }</td>
                                    <td>${stu.tel }</td>
                                    <td>${stu.major }</td>
                                    <td>${stu.stuclass }</td>
                                    <td style="width: 0px;;">
                                        <div style="width: 1px;">
                                                <%--                        		<button type="button" class="btn btn-info waves-effect waves btn-sm" style="margin: 0px auto;"--%>
                                                <%--                        		onclick="XiuGai('${stno }','${sname }','${tel }','${major }','${ stuclass}')" >--%>
                                                <%--                        			修改--%>
                                            <div class="profile-card-ctr">

                                                <!-- 模态框（Modal） -->
                                                <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                                                     aria-labelledby="myModalLabel" aria-hidden="true">
                                                    <div class="modal-dialog">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <h4 class="modal-title" id="myModalLabel">修改学生信息</h4>
                                                            </div>
                                                            <div class="modal-body">
                                                                <form action="updateStu" method="post">
                                                                    <input readonly="readonly" class="form-control"
                                                                           name="stno" id="stno" value="${stu.stno}">
                                                                    <input name="sname" class="form-control" type="text"
                                                                           id="sname" value="${stu.sname}"
                                                                           placeholder="请输入姓名">
                                                                    <input maxlength="11"
                                                                           onkeyup="value=value.replace(/[^(\d)]/g,'')"
                                                                           name="tel" class="form-control" type="tel"
                                                                           id="tel" value="${stu.tel }"
                                                                           placeholder="请输入电话号码">

                                                                    <input name="major" class="form-control" type="text"
                                                                           id="major" value="${stu.major}"
                                                                           placeholder="请输入专业">


                                                                    <input name="stuclass" id="stuclass"
                                                                           class="form-control" type="text"
                                                                           value="${stu.stuclass }" placeholder="请输入班级">
                                                                    <button type="submit" class="btn btn-primary">提交更改
                                                                    </button>
                                                                </form>

                                                            </div>
                                                            <div class="modal-footer">
                                                                <button type="button" class="btn btn-default"
                                                                        data-dismiss="modal">关闭
                                                                </button>
                                                            </div>
                                                        </div><!-- /.modal-content -->
                                                    </div><!-- /.modal -->
                                                </div>

                                            </div>
                                            <button class="btn btn-primary btn-lg waves-effect waves btn-sm"
                                                    data-toggle="modal" data-target="#myModal"
                                                    onclick="aa('${stu.stno}','${stu.sname}','${stu.tel}',
                                                            '${stu.major}','${stu.stuclass}')">
                                                修改
                                            </button>
                                            <button type="button" class="btn btn-warning waves-effect waves btn-sm"
                                                    style="margin: 0px auto;" onclick="sweet('${stu.stno}')">删除
                                            </button>
                                        </div>
                                    </td>


                                </tr>
                            </c:forEach>

                            <!--	描述：表结束 -->
                            </tbody>

                        </table>
                    </div>
                </div>


            </div>


            <!-- Bootstrap core JavaScript-->
            <script src="assets/js/jquery.min.js"></script>
            <script src="assets/js/popper.min.js"></script>
            <script src="assets/js/bootstrap.min.js"></script>

            <!-- simplebar js -->
            <script src="assets/plugins/simplebar/js/simplebar.js"></script>
            <!-- sidebar-menu js -->
            <script src="assets/js/sidebar-menu.js"></script>

            <!-- Custom scripts -->
            <script src="assets/js/app-script.js"></script>

            <!--Data Tables js-->
            <script src="assets/plugins/bootstrap-datatable/js/jquery.dataTables.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/dataTables.buttons.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/buttons.bootstrap4.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/jszip.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/pdfmake.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/vfs_fonts.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/buttons.html5.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/buttons.print.min.js"></script>
            <script src="assets/plugins/bootstrap-datatable/js/buttons.colVis.min.js"></script>

            <!--Sweet Alerts -->
            <script src="assets/plugins/alerts-boxes/js/sweetalert.min.js"></script>


            <script>
                function sweet(data) {
                    swal({
                        title: "您确定吗?",			//弹出标题
                        text: "该操作会删除该学生信息!",			//弹出文本
                        icon: "警告",				//警告图标   还有success error  info  不填就是不显示，默认不显示
                        buttons: true,
                        dangerMode: true,
                    })
                        .then((willDelete) => {
                            if (willDelete) {
                                console.log(data)
                                swal("学生信息已删除!", {
                                    icon: "success",
                                });
                                console.log("1")

                                window.location.href = "delStu?stno=" + data; 	//直接跳转到首页
                                console.log("1")
                                //嵌成果方法
                            } else {
                                swal("学生信息删除失败!");
                                //嵌失败方法
                            }
                        });
                }





                function CkPro(id) {
                    document.getElementById(id).remove();
                }

                //修改

            </script>

</body>

</html>
